package  
{
	import org.flixel.FlxButton;
	import org.flixel.FlxPoint;
	import org.flixel.FlxState;
	import org.flixel.FlxSprite;
	import org.flixel.FlxText;
	import org.flixel.FlxG;
	import org.flixel.FlxU;
	/**
	 * ...
	 * @author Lucas Mattos
	 */
	public class ScoreScreen extends FlxState
	{
		[Embed(source = "../assets/telas/back.png")]
		public var background:Class;
		public var backgroundSprite:FlxSprite;
		
		public var beginButton:FlxButton;
		public var text:FlxText;
		
		public function ScoreScreen() 
		{
			super();
			
			backgroundSprite = new FlxSprite(0, 0, background);
			add(backgroundSprite);
		}
		
		public override function create():void
		{
			text = new FlxText(30, 30, 740, "Hey Mr. "+PlayerData.levelNames[PlayerData.level]+" You finished this mandate, you 'scored' as follows:");
			text.setFormat(null, 20, 0xffffff,"center", 0);
			add(text);
			
			text = new FlxText(30, text.y+text.height+40, 740, "Your cash: "+PlayerData.dinheiro_atual);
			text.setFormat(null, 13, 0xffffff,"center", 0);
			add(text);
			
			text = new FlxText(30, text.y+text.height+10, 740, "Cash aquired during this mandate: "+PlayerData.dinheiro_lastSprint);
			text.setFormat(null, 13, 0xffffff,"center", 0);
			add(text);
			
			PlayerData.dinheiro_atual += PlayerData.dinheiro_lastSprint;
			
			text = new FlxText(30, text.y+text.height+10, 740, "New cash balance: "+PlayerData.dinheiro_atual);
			text.setFormat(null, 13, 0xffffff,"center", 0);
			add(text);
			
			if (PlayerData.dinheiro_lastSprint > PlayerData.highscore)
				PlayerData.highscore = PlayerData.dinheiro_lastSprint;
			
			text = new FlxText(30, text.y+text.height+10, 740, "Your best mandate: "+PlayerData.highscore);
			text.setFormat(null, 13, 0xffffff,"center", 0);
			add(text);
			
			PlayerData.dinheiro_total += PlayerData.dinheiro_lastSprint;
			
			text = new FlxText(30, text.y+text.height+10, 740, "Money 'acquired' during all mandates: "+PlayerData.dinheiro_total);
			text.setFormat(null, 13, 0xffffff,"center", 0);
			add(text);
			
			beginButton = new FlxButton(60, 560, "Continue!", beginGame);
			beginButton.x = Main.windowWidth / 2 - beginButton.width / 2;
			beginButton.scale.x = 2;
			beginButton.scale.y = 2;
			beginButton.color = 0xd5ce91;
			add(beginButton);
			
			PlayerData.won = true;
		}
		
		private function beginGame():void
		{		
			FlxG.switchState(new ShopState());
		}
		
	}

}